package com.beta.mytest;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * Created by vector on 2016/12/22.
 */
@Component
@EnableAsync
public class AsyncService {

    public void test() {
        printThread();
        asyncMethod();
    }

    @Async
    public void asyncMethod() {
        printThread();
        System.err.println("我是异步执行的方法...");
    }

    private void printThread() {
        System.err.println("thread - " + Thread.currentThread().getId());
    }

}
